package cn.yunlang.zhangZhongFei.controller;

import cn.yunlang.zhangZhongFei.service.SettleService;
import cn.yunlang.zhangZhongFei.vo.response.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import cn.yunlang.zhangZhongFei.entity.Settle;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/Settle")
@Api(tags = "公司入驻信息")
public class SettleController {

    @Resource
    private SettleService settleService;

    @ApiOperation("分页查")
    @GetMapping("/page")
    public R<IPage<Settle>> page(@RequestParam Integer pageNo,
                                 @RequestParam Integer pageSize){
        return settleService.pageSettle(pageNo, pageSize);
    }

    @GetMapping("/one")
    @ApiOperation("根据Id查一条")
    public R<Settle> one(@RequestParam Long settleId) {
        return settleService.getOne(settleId);
    }

    @GetMapping("/allow")
    @ApiOperation("通过入驻")
    public R<String> allow(@RequestParam Long settleId, HttpServletRequest request) {
        String type = request.getHeader("type");
        return settleService.allow(settleId, type);
    }

    @GetMapping("/disAllow")
    @ApiOperation("驳回入驻")
    public R<String> disAllow(@RequestParam Long settleId, HttpServletRequest request) {
        String type = request.getHeader("type");
        return settleService.disAllow(settleId, type);
    }
}